#include "spdlog/spdlog.h"
#include "spdlog/sinks/rotating_file_sink.h"
#include "spdlog/sinks/stdout_color_sinks.h"
#include "spdlog/sinks/daily_file_sink.h"
#include <memory>
#include <chrono>

static std::shared_ptr<spdlog::logger> mylogger;

int main(int argc, char* argv[])
{
    //spdlog::rotating_logger_mt 函数用于创建一个支持日志轮转的多线程安全日志记录器

    mylogger = spdlog::rotating_logger_mt("file_logger", "logs/rotating_file.txt", 1048576 * 5, 3);

    mylogger->set_pattern("%Y-%m-%d %H:%M:%S.%e	%l [%n-%P] [%t] %v");

    mylogger->flush_on(spdlog::level::info);

    spdlog::flush_every(std::chrono::seconds(2));

    int level = 2;
    
    mylogger->log(static_cast<spdlog::level::level_enum>(level), "this is a test");
}